package com.ylg.mybatis.core;

import java.util.Map;

public class SqlSessionFactory {

    /**
     * 事务管理器对象
     */
    private Transaction transaction;

    /**
     * 封装sql语句
     * key为sqlId 唯一标识
     * value为sql标签对象
     */
    private Map<String, MappedStatement> mappedStatements;

    public SqlSessionFactory(Transaction transaction, Map<String, MappedStatement> mappedStatements) {
        this.transaction = transaction;
        this.mappedStatements = mappedStatements;
    }

    public Transaction getTransaction() {
        return transaction;
    }

    public Map<String, MappedStatement> getMappedStatements() {
        return mappedStatements;
    }

    /**
     * 获取sqlSession对象用来执行sql语句
     * @return
     */
    public SqlSession openSqlSession(boolean autoCommit) {

        return new SqlSession(this, autoCommit);
    }
}
